< previous page page_390 next page >

Page 390
Property Get LastName() As String
LastName = mstrLastName
End Property

Property Get Salary() As Currency
Salary = mcurSalary
End Property
analysis.gifA Property Get procedure is just like a function because it returns a value to the calling procedure. To return a value from a function, you need to set the function name equal to the value to return. The preceding code returns the value of the private variables from each of the Property Get procedures by assigning the appropriate private variable the name of the Property Get procedure.

9f31265bb40b592b1929e18a47ab28e5.gif
TIP
A
Property Get procedure is like a function that returns a value.
Class Initialization
When an object is created from a class, all the private variables are initialized to the default value appropriate for that data type. If you create a private String variable, it will be initialized to a blank string. If you create a private Integer variable, it will be initialized to 0. In the preceding example, you created a private Currency variable, so the default value for this variable will be 0. To initialize this variable to a different value, you need to initialize it in the Class_Initialize event for the class.
To write the initialization code, select the left combo box from the class module window and open it so you can view the Class object. Select the Class object, and youll see that the right combo box now contains the Initialize event. Visual Basic will automatically place Sub Class_Initialize() into the module.

 
< previous page page_390 next page >

If you like this book, buy it!